package cn.task.controller;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.task.po.Task;
import cn.task.po.TaskVo;
import cn.task.service.TaskService;
@Controller
public class TaskController {
	@Autowired
	private TaskService taskService;
	@RequestMapping(value="/getTaskInform")
	public @ResponseBody TaskVo getTaskInform(HttpServletRequest request)
	{
		String taskId=request.getParameter("taskid");
		Task task=taskService.selectTaskById(taskId);
		Date releasedate=task.getReleasedate();
		SimpleDateFormat sdf=new SimpleDateFormat("yyyy年MM月dd日");
		String publishDate=sdf.format(releasedate);
		Date beginDate=task.getBegindate();
		String startDate=sdf.format(beginDate);
		Date endDate=task.getEnddate();
		String overDate=sdf.format(endDate);
		TaskVo taskVo=new TaskVo();
		taskVo.setStartDate(startDate);
		taskVo.setOverDate(overDate);
		taskVo.setPublishDate(publishDate);
		BeanUtils.copyProperties(task, taskVo);
		return taskVo;
	}
}
